<script setup>
import {queryApi} from "@/api/consignor"
import {ref,onMounted } from "vue"
const form=ref({
consignorName:""
})
const search=async()=>{
  let result=await queryApi(page.value,pageSize.value,form.value.consignorName)
  tableData.value=result.data.list
  total.value=result.data.total
  currentPage.value=page.value
}

const tableData=ref([])
const page=ref(1)
const pageSize=ref(10)
const total=ref(0)
const currentPage=ref(1)
const handleSizeChange=(val)=>{
  pageSize.value=val
  page.value=1
  search()
}

const handleCurrentChange=(val)=>{
  page.value=val
  search()
}

onMounted(()=>{
  search()
})
</script>

<template>
  <!--搜索框-->
<el-form :model="form" label-width="auto" style="max-width: 600px">
    <el-form-item>
      <el-input v-model="form.consignorName" placeholder="货主名称"/>
    </el-form-item>
    <el-button link type="primary" size="small" @click="search">查询</el-button>
</el-form>
<!--表格数据-->
 <el-table :data="tableData" style="width: 100%">
    <el-table-column prop="consignorName" label="货主名称" width="180" />
    <el-table-column prop="city" label="所在城市" width="180" />
    <el-table-column prop="address" label="详细地址" />
    <el-table-column prop="contact" label="联系方式" />
    <el-table-column prop="responsiblePerson" label="负责人" />
    <el-table-column prop="creator" label="创建人" />
    <el-table-column prop="createTime" label="创建时间" />
     <el-table-column fixed="right" label="Operations" min-width="120">
      <template #default>
        <el-button link type="primary" size="small" @click="handleClick">
          删除
        </el-button>
        <el-button link type="primary" size="small">修改</el-button>
      </template>
    </el-table-column>
  </el-table>
  <!--分页-->
  <el-pagination
      v-model:current-page="currentPage"
      v-model:page-size="pageSize"
      :page-sizes="[10, 20, 30, 40]"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
    />
</template>

<style>
</style>